import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/utils/_.dart';
import 'StaggeredGridViewPage.dart';



class SpannableCountCountPage extends StatelessWidget {
  final List<Think> thinkDataList;
   List<StaggeredTile> _tiles = [];
 ///照片高度系数
 double photoHeightCoefficient = 0;

  SpannableCountCountPage({required this.thinkDataList});


 waterFallFlowScaffolding(List<Think> thinkDataList) async{

   thinkDataList.asMap().keys.forEach((e)=>{
     photoHeightCoefficient = (thinkDataList[e].thinkIndexImageHeight!/(thinkDataList[e].thinkIndexImageWidth!/((Screen.width(Config.context)-12)/2)))/((Screen.width(Config.context)-12)/2),
     if(photoHeightCoefficient>1.5){
       thinkDataList[e].setThinkStatus = 1
     },
     _tiles.add(StaggeredTile.count(1,photoHeightCoefficient>1.5?photoHeightCoefficient:(thinkDataList[e].thinkIndexImageHeight!/(thinkDataList[e].thinkIndexImageWidth!/((Screen.width(Config.context)-12)/2))+75)/((Screen.width(Config.context)-12)/2) ))

   });

 }


 @override
 Widget build(BuildContext context) {

   waterFallFlowScaffolding(thinkDataList);
   return  StaggeredGridViewPage.count(
       title: 'Spannable (Count, Count)', crossAxisCount: 2, tiles: _tiles,thinkDataList:thinkDataList);
 }

}


